home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Add-Ons / MPW / MPW noweb 2.7 / src / perl / unmarkup < prev   
Encoding:
Text File  |  1995-09-05  |  1.3 KB  |  69 lines  |  [TEXT/MPS ]

  1. Perl -Sx "{0}" {"Parameters"} | Perl -pe 's/^@ $/@/'; Exit
  2.  
  3. #!perl
  4. # Copyright 1991 by Norman Ramsey.  All rights reserved.
  5. # See file COPYRIGHT for more information.
  6.  
  7. line: while (<>) {
  8.     chop;    # strip record separator
  9.     if (/^@begin docs 0$/) {
  10.     next line;
  11.     }
  12.     if (/^@begin docs /) {
  13.     printf '@ ';
  14.     }
  15.     if (/^@begin code /) {
  16.     }
  17.     if (/^@end [cd]o[dc][es] /) {
  18.     if ($dangling_text) {
  19.         printf "\n";
  20.     }
  21.     $dangling_text = 0;
  22.     printf '%s', $deflines;
  23.     if ($defline ne '') {
  24.         printf "%s\n", $defline;
  25.     }
  26.     $deflines = '';
  27.     $defline = '';
  28.     }
  29.     if (/^@defn /) {
  30.     printf '<<%s>>=', substr($_, 7, 999999);
  31.     }
  32.     if (/^@text $/) {
  33.     next line;
  34.     }
  35.     if (/^@text /) {
  36.     $s = '<<', s/$s/@<</g;
  37.     $s = '>>', s/$s/@>>/g;
  38.     printf '%s', substr($_, 7, 999999);
  39.     $dangling_text = 1;
  40.     }
  41.     if (/^@quote$/) {
  42.     printf (('[['));
  43.     $dangling_text = 1;
  44.     }
  45.     if (/^@endquote$/) {
  46.     printf ((']]'));
  47.     $dangling_text = 1;
  48.     }
  49.     if (/^@nl$/) {
  50.     printf "\n";
  51.     $dangling_text = 0;
  52.     }
  53.  
  54.     if (/^@index defn /) {
  55.     if ($defline eq '') {
  56.         $defline = '@ %def';
  57.     }
  58.     $defline = $defline . ' ' . substr($_, 13, 999999);
  59.     }
  60.     if (/^@index nl$/) {
  61.     $deflines = $deflines . $defline . "\n";
  62.     $defline = '';
  63.     }
  64.     if (/^@use /) {
  65.     printf '<<%s>>', substr($_, 6, 999999);
  66.     $dangling_text = 1;
  67.     }
  68. }
  69.